package sample6;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class JTableTestFrame extends JFrame {
	private final int WIDTH = 600;
	private final int HEIGHT = 400;

	String[][] data = { { "1.1", "1.2", "1.3" }, { "2.1", "2.2", "2.3" }, { "3.1", "3.2", "3.3" } };
	String[] columns = { "col1", "col2", "col3" };

	public static void main(String[] args) {
		new JTableTestFrame("JTable Ornegi");
	}

	public JTableTestFrame(String title) {
		setSize(WIDTH, HEIGHT);
		setTitle(title);
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				super.windowClosing(e);
				System.out.println("kapaniyor..");
				System.exit(NORMAL);
			}
		});

		JTable table = new JTable(data, columns);
		JScrollPane scrollPane = new JScrollPane(table);

		add(scrollPane);

		setVisible(true);
	}
}
